"""
用做切片式文件上传
"""
# 整个项目的启动文件
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from api import api
from core.settings import settings

app = FastAPI(title=settings.PROJECT_NAME, openapi_url=f"{settings.DEFAULT_PREFIX}/openapi.json")

if settings.BACKEND_CORS_ORIGINS:  # 设置跨域
    app.add_middleware(
        CORSMiddleware,
        allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

# open_api的路由: http://127.0.0.1/docs
app.include_router(api.api_router, prefix=settings.DEFAULT_PREFIX)
if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app, host="0.0.0.0", port=5211)
